#/usr/bin/env bash

1，安装 chrony
yum install -y chrony
2，启动 chrony
systemctl start chronyd
3，自启
systemctl enable chronyd
4，配置
vim /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#pool 2.centos.pool.ntp.org iburst （这一行注释掉，增加以下两行）
server ntp.aliyun.com iburst
server cn.ntp.org.cn iburst



# 检查安装keepalived
if ! keepalived -C >/dev/null 2>&1;then
	yum install keepalived -y
fi

#






function kvmc(){
	kvmname=${1}
	qemu-img create -f qcow2 /ssd1/kvm/${kvmname}.qcow2 400G
	virt-install --name ${kvmname} --ram 65536 \
	--vcpus=8 \
	--location /ssd1/iso/c7.9-2009.iso \
	--disk path=//ssd1/kvm/${kvmname}.qcow2 \
	--os-type=linux \
	--graphics vnc,listen=0.0.0.0 \
	--network bridge=virbr0,model='e1000'
}

function kvmc(){
	kvmname=${1}
	qemu-img create -f qcow2 /ssd1/kvm/${kvmname}.qcow2 400G
	virt-install \
	--name ${kvmname} \
	--ram 65536 \
	--vcpus=8 \
	--location /ssd1/iso/CentOS-8.2.2004-x86_64-dvd1.iso \
	--disk path=/ssd1/kvm/${kvmname}.qcow2 \
	--os-type=linux \
	--graphics vnc,listen=0.0.0.0 \
	--network bridge=virbr0,model='e1000'
}



function k0(){
	kvmname=${1}
	qemu-img create -f qcow2 /ssd1/kvm/${kvmname}.qcow2 400G
	virt-install \
	--name ${kvmname} \
	--memory 65536 \
	--vcpus=8 \
	--location /ssd1/iso/CentOS-8.2.2004-x86_64-dvd1.iso \
	--disk path=/ssd1/kvm/${kvmname}.qcow2 \
	--os-type=linux \
	--graphics vnc,listen=0.0.0.0 \
	--network bridge=virbr0,model='e1000' \
	--extra-args=ro
}


iptables -A INPUT -p tcp --dport 8995 -j ACCEPT


iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 8993 -j DNAT --to-destination 192.168.123.233:22
iptables -t nat -A POSTROUTING -d 192.168.123.233/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21

iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 8994 -j DNAT --to-destination 192.168.123.4:22
iptables -t nat -A POSTROUTING -d 192.168.123.4/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21


iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 8996 -j DNAT --to-destination 192.168.123.111:22
iptables -t nat -A POSTROUTING -d 192.168.123.111/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21

iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 8997 -j DNAT --to-destination 192.168.123.79:22
iptables -t nat -A POSTROUTING -d 192.168.123.79/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21

iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 8998 -j DNAT --to-destination 192.168.123.106:22
iptables -t nat -A POSTROUTING -d 192.168.123.106/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21

iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 8999 -j DNAT --to-destination 192.168.123.215:22
iptables -t nat -A POSTROUTING -d 192.168.123.215/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21

iptables -t nat -A PREROUTING -d 10.31.65.21/32 -p tcp --dport 9000 -j DNAT --to-destination 192.168.123.233:22
iptables -t nat -A POSTROUTING -d 192.168.123.233/32 -p tcp --dport 22 -j SNAT --to-source 10.31.65.21





iptables -A INPUT -p tcp --dport 8995 -j ACCEPT
iptables -A INPUT -p tcp --dport 8070 -j ACCEPT




iptables -I FORWARD -p tcp --dport 22 -j ACCEPT

iptables -t nat -A PREROUTING -d 10.35.165.176/32 -p tcp --dport 8888 -j DNAT --to-destination 192.168.122.11:8888
iptables -t nat -A POSTROUTING -d 192.168.122.11/32 -p tcp --dport 8888 -j SNAT --to-source 10.35.165.176

iptables -t nat -A PREROUTING -d 10.35.165.176/32 -p tcp --dport 8070 -j DNAT --to-destination 192.168.122.11:8070
iptables -t nat -A POSTROUTING -d 192.168.122.11/32 -p tcp --dport 8070 -j SNAT --to-source 10.35.165.176


iptables -t nat -I PREROUTING -d 10.35.165.176 -p tcp -m tcp --dport 8203 -j DNAT --to-destination 192.168.122.11:6203
iptables -t nat -A POSTROUTING -d 192.168.122.11/32 -p tcp --dport 6203 -j SNAT --to-source 10.35.165.176


















